<template>
	<view class="container">
		<scroll-view scroll-y="true" class="list" @scrolltolower="loadMore">
			<view class="list-item" v-for="(item,index) in list" :key="item.order_sn">
				<text>提现 <text>￥{{item.money}}</text></text>
				<view>
					<text>{{item.createtime}}</text>
					<text v-if="item.state == 1" class="check">申请中</text>
					<text v-if="item.state == 2" class="achieve">审核通过</text>
					<text v-if="item.state == 3" class="achieve">已打款</text>
					<text v-if="item.state == 4" class="filed">驳回</text>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		cashRecord
	} from '../../../api/api.js'
	export default {
		data() {
			return {
				list: [],
				total: '',
				current_page: 1,
				limit: 10,
				last_page: 0
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			getList(loadMore) {
				cashRecord({
					limit: this.limit,
					page: this.current_page
				}).then(res => {
					if(loadMore){
						if(this.current_page <= this.last_page){
							for (let i = 0; i < res.data.data.length; i++) {
								this.list.push(res.data.data[i])
							}
						}else{
							uni.showToast({
								icon:'none',
								title:'没有更多提现记录了'
							})
						}
					}else{
						this.list = res.data.data
					}
					this.total = res.data.total
					this.last_page = res.data.last_page
					this.current_page = res.data.current_page + 1
				})
			},
			loadMore() {
				console.log("加载更多")
				this.getList('loadMore')
			},
		},
	}
</script>

<style scoped lang="scss">
	.container {
		width: 100%;
		height: 100%;
	}

	.list {
		width: calc(100% - 60upx);
		height: 100%;
		padding: 0 30upx;

		.list-item {
			width: 100%;
			height: 100upx;
			padding: 10upx 0;
			border-bottom: 1upx solid #ECECEC;
			display: flex;
			flex-direction: column;
			justify-content: space-around;


			text {
				font-size: 28upx;
				color: #333333;

				text {
					font-size: 28upx;
					color: #1E1E1E;
					margin-left: 15upx;
				}
			}

			view {
				width: 100%;
				display: flex;
				justify-content: space-between;

				text {
					font-size: 24upx;
					color: #999;
				}

				.achieve,
				.check {
					font-size: 28upx;
					color: #666;
				}

				.filed {
					color: #f00;
				}

				.check {
					color: #3EB9FF;
				}
			}
		}
	}
</style>
